<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>string</title>
</head>
<body>
    
    <script>
    
        {

            // 常用的方法 (参数 -> 返回的结果)
            let str = '    abcdef    1234';
            let s = str.substr(0,4);
            let s1 = str.substring(0,5);
            let s2 = str.slice(0,6);
            let s3 = str.charAt(4);
            let s4 = str.split('');
            let s5 = str.replace(/\s+/g,'');
            console.log(s);
            console.log(s1);
            console.log(s2);
            console.log(s3);
            console.log(s4);
            console.log(s5);

        }
    
    </script>

</body>
</html>